import CommonPageMixin from "./common-page-mixin.js";
var CustomNaviMixin = {
	mixins: [CommonPageMixin],
	data: function() {
		return {
			alwaysShowNaviTitle: false,
			pageScrollHeight: 0,
		}
	},
	computed: {
		navibg: function() {
			let alpha = 0;
			if (this.pageScrollHeight > 0) {
				alpha = this.pageScrollHeight / 100;
			}
			if (alpha > 1) {
				alpha = 1;
			}
			return 'rgba(255,255,255,' + alpha + ')'
		},
		naviColor: function() {
			let alpha = 0;
			if (this.pageScrollHeight > 0) {
				alpha = this.pageScrollHeight / 100;
			}
			if (alpha > 1) {
				alpha = 1;
			}
			if (this.alwaysShowNaviTitle) {
				alpha = 1 - alpha
				const r = Math.round(255 * alpha);
				const g = Math.round(255 * alpha);
				const b = Math.round(255 * alpha);
				return `rgba(${r}, ${g}, ${b}, 1)`;
			} else {
				return 'rgba(0,0,0,' + alpha + ')'
			}
		}
	},
	onPageScroll: function(e) {
		this.pageScrollHeight = e.scrollTop;
	},
	methods: {
		_naviBack() {
			uni.navigateBack()
		},
	}
}

module.exports = CustomNaviMixin;